package com.axzhengxin.platform.afterloan.controller;

import com.axzhengxin.platform.afterloan.domain.FspCorInf;
import com.axzhengxin.platform.afterloan.service.IFspCorInfoService;
import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Optional;

/**
 * FspCorInfController
 *
 * @author jiangnan
 * @date 2021/3/3
 */
@Slf4j
@RestController
@RequestMapping(path = "/afterloan/customer")
public class FspCorInfController extends BaseController {

    private IFspCorInfoService fspCorInfoService;

    public FspCorInfController(IFspCorInfoService fspCorInfoService) {
        this.fspCorInfoService = fspCorInfoService;
    }

    /*@PreAuthorize("@ss.hasPermi('afterloan:customer:list')")*/
    @GetMapping(path = "/list")
    public TableDataInfo list(FspCorInf fspCorInf) {
        startPage();
        List<FspCorInf> fspCorInfList = fspCorInfoService.getMyCustomerInfoList(fspCorInf);
        return getDataTable(fspCorInfList);
    }

    /*@PreAuthorize("@ss.hasPermi('afterloan:customer:detail')")*/
    @GetMapping(path = "/{customerId}")
    public AjaxResult detail(@PathVariable("customerId") String customerId) {
        return Optional.ofNullable(fspCorInfoService.getCustomerInfoById(customerId))
                .map(AjaxResult::success)
                .orElse(new AjaxResult(HttpStatus.NOT_FOUND, "未找到指定用户"));
    }

}
